<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>汽车保养与维修系统</title>
	<link href="<?php echo base_url('web');?>/css/bootstrap.min.css" rel="stylesheet" />
	<script src="<?php echo base_url('web')?>/js/jquery-3.2.0.min.js" ></script>
	<script src="<?php echo base_url('web')?>/js/bootstrap.min.js" ></script>
</head>
<body style="padding:100px;">
	<div class="panel panel-default">
		<!-- Default panel contents -->
		<div class="panel-heading">预约工作人员</h1></div>

		<!-- Table -->
		<table class="table">
			<style>
				.table {text-align:center;}
				.table th {text-align:center;}
			</style>
			<tbody>
				<tr>
					<th>车型</th>
					<td>
						<select id="type" name="type">
							<option value="0">请选择车型</option>
							<?php 
								$str ='';
								foreach($type as $v){
									$str .= '<option value="'.$v["classid"].'">'.$v["name"].'</option>';
								}
								echo $str;
							?>
						</select>
					</td>
				</tr>
				<tr>
					<th>预约时间</th>
					<td><input id="time" type="text" name="time"><label>填写如：2018-05-25</label></td>
				</tr>
				<tr>
					<th>工作人员</th>
					<td>
						<select id="worker" name="worder">
							<option value="1">后台分配</option>
							<?php 
								$str ='';
								foreach($workers as $v){
									$str .= "<option value=\"".$v["classid"]."\">".$v["name"]."</option>";
								}	
								echo $str;
							?>
						</select>
					</td>
				</tr>
				<tr>
					<th>提交</th>
					<td><button id="submit" type="submit" name="submit">提交预约</button></td>
				</tr>
			</tbody>
		</table>
	</div>
	<script>
		var $submit = $('#submit');
		$submit.on('click',function(){
			var data = {
				'type' : $('#type').val(),
				'time' : $('#time').val(),
				'worker' : $('#worker').val()
			};
			if(data['type']==0){
				alert('请选择车型');
				return;
			}
			console.log(data);
			$.get(window.parent.RESERVE_USER_URL,data,function(res){
				if(res.code == 200){
					alert(res.data.msg);
					console.log(window.parent);
					window.parent.$lis.removeClass('active');
					window.parent.$myReservation.addClass('active');
					window.location.href = window.parent.RESERVATION_URL;
				}else{
					alert(res.msg);
					if(res.code == 401){
						window.parent.login();
					}
				}
				
			},'json');
		});
		
	</script>
</body>
</html>